<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<base href="<%=basePath%>">
<title>超市后台</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.4.5/angular.min.js"></script>
<script src="${pageContext.request.contextPath}/js/MD5.js"></script>
<style>
.chaoshi_title {
	width: 100%;
	height: 30px;
	line-height: 30px;
	background-color: #3aa9d2
}

.box_content {
	height: 40px;
	padding-left: 30px
}

.chaoshi_title>ul {
	width: 100%;
	height: 100%;
	float: left;
	text-align: center
}

.chaoshi_title>ul>li {
	display: block;
	float: left;
	width: 8.5%
}

.chaoshi_title>ul>li:last-child {
	width: 15%
}

.chaoshi_title>ul>li:nth-child(2) {
	text-align: left
}

.chaoshi_commodity>ul>li:last-child {
	width: 15%
}

.chaoshi_commodity {
	width: 100%;
	height: 60px;
	line-height: 60px;
	border-bottom: 1px solid #c1c1c1
}

.chaoshi_commodity>ul {
	width: 100%;
	height: 100%;
	float: left
}

.chaoshi_commodity>ul>li {
	display: block;
	float: left;
	width: 8.5%;
	text-align: center
}

.chaoshi_commodity>ul>li>img {
	float: left;
	padding: 0;
	margin: 0
}

.chaoshi_commodity>ul>li>button {
	height: 30px;
	width: 70px;
	line-height: 24px;
	border-radius: 4px;
	background-color: #18bcc9;
}

img {
	width: 60px;
	height: 50px
}

#motai_box {
	position: fixed;
	z-index: 100;
	background: rgba(0, 0, 0, 0.2);
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	visibility: hidden
}

#motai_box1 {
	position: absolute;
	width: 500px;
	height: 400px;
	top: 50%;
	left: 50%;
	margin-left: -250px;
	margin-top: -200px;
	background-color: #fdfdfd
}

.pageChange {
	float: right;
	color: #337ab7;
}

.pageChange>span {
	cursor: pointer
}

.pageChange>span:hover {
	color: blue
}
</style>
<script type="text/javascript">
	$(function() {
		//$("#deliveryform").submit();
	})
</script>
</head>
<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">
		<section id="main">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div">
					<div class="main_title">
						<span>爆款仓库</span>
					</div>
					<div class="blank"></div>
					<!-- <form class="form-inline" id="superFormList" action=""
						style="margin-top: 30px;margin-left: 20px">
						
						<div class="form-group">
							<label for="ProductName"> 商品名称:</label> <input type="text"
								class="form-control" id="productName" placeholder="">
						</div>
						<div class="form-group">
							<label for="barCode"> 商品条码:</label> <input type="text"
								class="form-control" id="barCode" placeholder="">
						</div>
						<div class="form-group">
							<label>是否上架:</label> <select id="putaway" class="form-control"
								name="putaway">
								<option value="-1">请选择</option>
								<option value="1">已上架</option>
								<option value="0">未上架</option>
							</select>
						</div>
						<div class="form-group">
							<label>是否推荐:</label> <select id="recommend" class="form-control"
								name="recommend">
								<option value="-1">请选择</option>
								<option value="1">已推荐</option>
								<option value="0">未推荐</option>

							</select>
						</div>
						<button type="button" onclick="selectinfo()"
							class="btn btn-primary">立即查询</button>
					</form> -->
					<input style="display:none" value="7" id="pageCount" />
				</div>
				<div class="force-overflow1-1">
					<table class="table table-condensed table-bordered table-hover"
						id="showtable" style="text-align: center">
						<tr style="background-color: #59c7d2">
							<th style="text-align: center">序号</th>
							<th style="text-align: center">略缩图</th>
							<th style="text-align: center">商品名称</th>
							<th style="text-align: center">商品条码</th>
							<th style="text-align: center">爆款价</th>
							<th style="text-align: center">商品数量</th>							
							<th style="text-align: center">修改</th>
						</tr>
						
					</table>
					<div class="bgBox" style="visibility:hidden" >
							<div id="box">
								<div class="box_header textYellow">
									<span>详细资料</span>
								</div>
								<div class="scrollbar1-2" id="style1-1">
									<div class="form-horizontal">										
										<div class="form-group">
											<label class="col-sm-3 control-label">商品数量</label>
											<div class="col-sm-6">
												<input type="text" class="form-control" id="productCount"
													placeholder="请输入商品数量"><input style="display:none" id="productID"/>
											</div>
										</div>
									</div>
									<div class="force-overflow1-2"></div>
								</div>
								<div class="box_footer">
									<ul>
										<li id="sureDetail" onclick="motaiHidden()">关闭</li>
										<li onclick="submitProduct(this)">提交</li>
									</ul>
								</div>
							</div>
						</div>
					<div class="pageChange">
						<span onclick="prePage()">&nbsp;&nbsp;上一页&nbsp;&nbsp;</span> <span
							onclick="nextPage()">&nbsp;&nbsp;下一页&nbsp;&nbsp;</span> <em>
							&nbsp; 第&nbsp;<span id="pageNum">1</span>&nbsp;页&nbsp;&nbsp;
						</em> <em>/&nbsp;&nbsp;共&nbsp;<span id="totalpage"></span>&nbsp;页
						</em> <em>&nbsp;&nbsp;&nbsp;跳到第<input id="searchInput"
							style="width:46px" maxlength="4" type="text">页
						</em>
						<button class="btn btn-primary" onclick="searchPage()">搜索</button>
					</div>
				</div>
			</div>
		</section>


	</div>

</body>
<script type="text/javascript">
	
	function deleteProduct(e) { //删除商品
		$.post(urls+"productaAction/deleteSuperMarketEntrepot",
			{
				id : e
			},
			function(res) {
				if (res == true) {
					selectinfo()
				} else {
					alert("删除商品失败")
				}
			})

	}
	function motaiHidden() { //隐藏详情页面
		$(".bgBox").css("visibility", "hidden")
	}
	$(function() {
		selectinfo()
	})

	

	function selectinfo() {
		var barCode = $("#barCode").val();
		var pageNum = $("#pageNum").html();
		var pageCount = $("#pageCount").val();
		var productName = $("#productName").val();
		var putaway = $("#putaway").find("option:selected").val()
		var recommend = $("#recommend").find("option:selected").val()
		if (productName == "") {
			productName = null;
		}
		if (barCode == "") {
			barCode = null;
		}
		if (recommend==-1) {
			recommend = null
		}
		if (putaway==-1) {
			putaway = null
		}
		$.post(urls + "productaAction/getProduct",
			{
			   putaway:putaway,
			   recommend:recommend,
				superId : localStorage.getItem("id"),
				barCode : barCode,
				pageNum : pageNum,
				pageCount : pageCount,
				productName : productName,
				putaway:1,
				hot:1
			},
			function(data) {
				//console.log(data)
				if (data) {
					var totalpage = data.totalpage;
					var orderlist = data.superlist;
					var table = $("#showtable");
					$("tr").remove(".addtr");
					for (var i = 0; i < orderlist.length; i++) {
						var append = "<tr class='addtr'><td>" + (i + 1) + "</td>" +
							"<td ><img src='/goods/" + orderlist[i].productSimg + "' alt='加载中'/> </td>" +
							"<td>" + orderlist[i].productName + "</td>" +
							"<td>" + orderlist[i].barCode + "</td>" +
							"<td>" + orderlist[i].discountPrice + "</td>" +
							"<td>" + orderlist[i].inactive3 + "</td>" +						
							"<td><button class='btn btn-info' onclick='detailinfo(\"" 
						    + orderlist[i].productName +"|$"
							+ orderlist[i].referenceValue +"|$"
							+ orderlist[i].promotionPrice +"|$"
							+ orderlist[i].discountPrice +"|$"
							+ orderlist[i].inactive3 +"|$"
							+ orderlist[i].id 
							+
							"\")'>修改</button></td></tr>";
						table.append(append);
					}
					$("#totalpage").html(totalpage);
				}
			}
			, "json"
		)
	}
	function detailinfo(e) { 	
		var attr = e.split("|$");
		$(".bgBox").css("visibility", "visible");
		$("#productNames").val(attr[0]);
		$("#price").val(attr[1])	;
		$("#salePrice").val(attr[2])	;
		$("#vipPrice").val(attr[3])	;
		$("#productCount").val(attr[4])	;
		$("#productID").val(attr[5])
	}
	function submitProduct() {
		if ($(productCount).val()) {
			$.post(urls + "productaAction/updateSuperMarketEntrepot",
				{
					inactive3 : $("#productCount").val(),
					superId : localStorage.getItem("id"),
					id:$("#productID").val(),
				}, function(res) {
					if (res == false) {
						alert("提交失败")
					} else {
						alert("提交成功");
						selectinfo();
						motaiHidden()
					}
				})
		} else {
			alert("请填写完整商品信息")
		}
		
	}
	function motaiHidden() {
		$(".bgBox").css("visibility", "hidden");
	}
	function recommends(id,recommend){
			$.post(urls+"productaAction/updateSuperMarketEntrepot",
				{
					superId : localStorage.getItem("id"),
					id :id ,
					recommend : recommend
				},
				function(res){
				selectinfo()
				}
			);
			
	}
	function putaways(id,putaways){
			$.post(urls+"productaAction/updateSuperMarketEntrepot",
				{
					superId : localStorage.getItem("id"),
					id :id ,
					putaway : putaways
				},
				function(res){
				selectinfo()
				}
			);
			
	}
</script>
</html>
